/*
 * Dialogo.java
 *
 * Created on 25 de marzo de 2008, 14:08
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package mvc.wiew;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JDialog;

/**
 *
 * @author notebook
 */
public class Dialogo extends JDialog{
    
    /** Creates a new instance of Dialogo */
    private Dialogo (String titulo) {
        Dimension p=Toolkit.getDefaultToolkit().getScreenSize();
        ini(titulo,(int)(p.getWidth()*.9), (int)(p.getHeight()*.9));
    }
    private Dialogo (String titulo, int ancho, int alto) {
        ini(titulo, ancho, alto);
    }
    
    private void ini(String titulo, int ancho, int alto){
        setTitle(titulo);
        setModal(true);
        getContentPane().setLayout(null);
        Dimension p=Toolkit.getDefaultToolkit().getScreenSize();
        this.setSize(ancho, alto);
        setLocation((int)((p.getWidth()-getWidth())/2),(int)((p.getHeight()-getHeight())/2));
        this.setVisible(true);
        
    }
    
    public void add(Container c){
        this.getContentPane().add(c);
    }
    
    public static Dialogo creo(String titulo){
        return new Dialogo(titulo);
    }
    public static Dialogo creo(String titulo, int ancho, int alto){
        return new Dialogo(titulo, ancho, alto);
    }
}
